package com.ly.consumer.thread;

class MyRunnableShare implements Runnable {
    private int ticket = 12;
    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.println(Thread.currentThread().getName()+"卖出了一张票,还剩"+ticket--);
        }
    }
}
public class Demo03 {
    //动物园卖票 一共12张票 分3个窗口去卖票 12张票是共享资源
    public static void main(String[] args) {
        MyRunnableShare myRunnableShare = new MyRunnableShare();
        Thread t1 = new Thread(myRunnableShare,"窗口1");
        Thread t2 = new Thread(myRunnableShare,"窗口2");
        Thread t3 = new Thread(myRunnableShare,"窗口3");
        t1.start();
        t2.start();
        t3.start();
    }
}
